import QtQuick
import QtQuick.Window

Image {
    id: root
    source: "images/background.png"
    property int padding: 40
    property bool running: false

    Image {
        id: qq
        source: "images/qq.png"
        x: root.padding; y: (root.height - height) / 2
        width: 128; height: 128

//        通用PropertyAnimation, 专用的Animcation效率更高
        NumberAnimation on x {
            to: root.width - qq.width - root.padding
            duration: 3000 // 3 seconds
            running: root.running
        }

        RotationAnimation on rotation {
            to: 360
            duration: 3000
            running: root.running
        }

//        OpacityAnimator on opacity {
//            to: 0
//            duration: 3000
//            running: root.running
//        }
    }

    OpacityAnimator on opacity {
        target: qq // 如果Animator放到了Image外面, 只需要为其指定target
        to: 0
        duration: 3000
        running: root.running
    }

    MouseArea {
        anchors.fill: parent
        onClicked: root.running = true
    }
}
